package com.ks.community.service.impl;

import com.ks.community.entity.Menu;
import com.ks.community.entity.MenuIngredient;
import com.ks.community.entity.vo.MenuIngredientVo;
import com.ks.community.mapper.MenuIngredientMapper;
import com.ks.community.service.MenuIngredientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dCoder
 * @since 2022-04-04
 */
@Service
public class MenuIngredientServiceImpl extends ServiceImpl<MenuIngredientMapper, MenuIngredient> implements MenuIngredientService {

    @Override
    public void addIngredientByName(MenuIngredientVo menuIngredientVo) {
        MenuIngredient menuIngredient = new MenuIngredient();
        String MenuName  = menuIngredientVo.getMenuName();
        String IngredientName = menuIngredientVo.getIngredientName();
        String menuId = baseMapper.selectById(MenuName).getMenuId();
        String ingredientId = baseMapper.selectById(IngredientName).getIngredientId();
        menuIngredient.setMenuId(menuId);
        menuIngredient.setMenuIngredientId(ingredientId);
        baseMapper.insert(menuIngredient);

    }

    @Override
    public void addOne(MenuIngredient menuIngredient) {
       baseMapper.insert(menuIngredient);
    }

}
